Skip to content

Conversation

@garthvh
Copy link
Member

@garthvh garthvh commented Jan 5, 2026

Don't append new devices to the list of discovered devices if the app is in the background, seems to cause crashes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses crashes caused by appending new devices to the discovery list when the app is in the background. The solution introduces a background state flag that prevents device list modifications during background/inactive states.

Key Changes

  • Added isInBackground flag tracking in AccessoryManager based on scene phase
  • Version bumped from 2.7.6 to 2.7.7 across all targets

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Meshtastic/MeshtasticApp.swift Added logic to set accessoryManager.isInBackground flag when scene phase changes, preventing device discovery updates when app is not active
Meshtastic.xcodeproj/project.pbxproj Updated marketing version from 2.7.6 to 2.7.7 across all build configurations and targets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

garthvh and others added 2 commits January 4, 2026 20:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@garthvh garthvh merged commit 487f24b into 2.7.7 Jan 5, 2026
2 checks passed
@garthvh garthvh deleted the accessorymanager-background-discovery branch January 5, 2026 04:38
@compumike
Copy link
Contributor

@garthvh FYI this change seems to break automatic reconnection when the app is in the background: shouldAutomaticallyConnectToPreferredPeripheral / connectToPreferredDevice relies on it being present in devices.

Test sequence:

  • connect to a node (BLE)
  • put app in background
  • reboot the node
  • watch the app logs

With this PR, it just stops at [Discovery] Found preferred peripheral and doesn't attempt to reconnect.

garthvh added a commit that referenced this pull request Jan 8, 2026
garthvh added a commit that referenced this pull request Jan 8, 2026
garthvh added a commit that referenced this pull request Jan 15, 2026
* Bump version

* update the translations (#1540)

update the translations

* Don't alert (with sound: .default) when updating Live Activity (#1536)

* Fix adding channels (#1532)

* Full translation into Spanish (#1529)

* tapback with any emoji (#1538)

* Call clearStaleNodes at start of sendWantConfig (#1535)

* NFC Tag contact (#1537)

* Accessorymanager background discovery (#1542)

* Don't add new BLE  devices to the device list in the backgournd

* Bump version

* Update Meshtastic/MeshtasticApp.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/MeshtasticApp.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Revert "Full translation into Spanish (#1529)" (#1543)

This reverts commit f25fdfb.

* Revert "update the translations (#1540)" (#1544)

This reverts commit cb2fd8c.

* Revert "NFC Tag contact (#1537)" (#1545)

This reverts commit 5c22b8b.

* Update Meshtastic/Views/Messages/TapbackInputView.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/Helpers/EmojiOnlyTextField.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Revert "Accessorymanager background discovery (#1542)" (#1553)

This reverts commit 487f24b.

* Make BLE Transport an actor to fix background discovery crashes

* Update protobufs

* Protobufs

* Remove UI Kit code, clean up waypoint form emoji picker

* Remove redundant nested Task in tapback emoji handler (#1552)

* Initial plan

* Remove nested Task block in tapback handler

Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>

* Delete empty file

* Handle nil for emoji keyboard type extension

* Remove UI kit method from waypoint form emoji picker

* Remove UI kit emoji picker from tapback

* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Throw too many retries error again, remove return

---------

Co-authored-by: MGJ <62177301+MGJ520@users.noreply.github.com>
Co-authored-by: Mike Robbins <mrobbins@alum.mit.edu>
Co-authored-by: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com>
Co-authored-by: Alvaro Samudio <alvarosamudio@protonmail.com>
Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>
garthvh added a commit that referenced this pull request Jan 15, 2026
* Bump version

* update the translations (#1540)

update the translations

* Don't alert (with sound: .default) when updating Live Activity (#1536)

* Fix adding channels (#1532)

* Full translation into Spanish (#1529)

* tapback with any emoji (#1538)

* Call clearStaleNodes at start of sendWantConfig (#1535)

* NFC Tag contact (#1537)

* Accessorymanager background discovery (#1542)

* Don't add new BLE  devices to the device list in the backgournd

* Bump version

* Update Meshtastic/MeshtasticApp.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/MeshtasticApp.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Revert "Full translation into Spanish (#1529)" (#1543)

This reverts commit f25fdfb.

* Revert "update the translations (#1540)" (#1544)

This reverts commit cb2fd8c.

* Revert "NFC Tag contact (#1537)" (#1545)

This reverts commit 5c22b8b.

* Update Meshtastic/Views/Messages/TapbackInputView.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Meshtastic/Helpers/EmojiOnlyTextField.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Revert "Accessorymanager background discovery (#1542)" (#1553)

This reverts commit 487f24b.

* Update protobufs

* Remove UI Kit code, clean up waypoint form emoji picker

* Remove redundant nested Task in tapback emoji handler (#1552)

* Initial plan

* Remove nested Task block in tapback handler

Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>

* Delete empty file

* Handle nil for emoji keyboard type extension

* Remove UI kit method from waypoint form emoji picker

* Remove UI kit emoji picker from tapback

* Add Exchange User Info (#1550)

* Emoji keyboard (#1559)

* Add file missing from project, must have merged badly

* Remove ui kit emoji keyboard

* Discovery background fixes (#1561)

* Make BLE Transport an actor to fix background discovery crashes

* Protobufs

* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Throw too many retries error again, remove return

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Increase connection timeout

* Update protobufs

* Revert "Fix adding channels (#1532)" (#1562)

This reverts commit bff8ca0.

---------

Co-authored-by: MGJ <62177301+MGJ520@users.noreply.github.com>
Co-authored-by: Mike Robbins <mrobbins@alum.mit.edu>
Co-authored-by: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com>
Co-authored-by: Alvaro Samudio <alvarosamudio@protonmail.com>
Co-authored-by: Mathew Kamkar <578302+matkam@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>
Co-authored-by: Brian Hardie <777730+bhardie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants